<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Distributed cluster," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="说明：Kafka And Zookeeper。">
<meta name="keywords" content="Distributed cluster">
<meta property="og:type" content="article">
<meta property="og:title" content="Kafka and Zookeeper">
<meta property="og:url" content="http://bebetter.site/2017/01/12/Software/Distributed cluster and big data 分布式集群与大数据/Kafka and Zookeeper/index.html">
<meta property="og:site_name" content="gatewayzy">
<meta property="og:description" content="说明：Kafka And Zookeeper。">
<meta property="og:updated_time" content="2017-01-12T05:58:56.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Kafka and Zookeeper">
<meta name="twitter:description" content="说明：Kafka And Zookeeper。">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"right","display":"always"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://bebetter.site/2017/01/12/Software/Distributed cluster and big data 分布式集群与大数据/Kafka and Zookeeper/"/>

  <title> Kafka and Zookeeper | gatewayzy </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">gatewayzy</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">blog of gatewayzy</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Kafka and Zookeeper
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-01-12T13:58:15+08:00" content="2017-01-12">
              2017-01-12
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Softwares/" itemprop="url" rel="index">
                    <span itemprop="name">Softwares</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><strong>说明：</strong>Kafka And Zookeeper。<br><a id="more"></a></p>
<hr>
<h2 id="Kafka-And-Zookeeper-简介"><a href="#Kafka-And-Zookeeper-简介" class="headerlink" title="Kafka And Zookeeper 简介"></a>Kafka And Zookeeper 简介</h2><ul>
<li>kafka是分布式消息队列Message Queue产品，依赖于Zookeeper进行集群的消息控制。</li>
<li>zookeeper(简写为zk)是分布式服务器管理，为高层应用提供服务。</li>
<li>分布式集群的优点是可横向扩展，人多力量大，局部故障仍可运行。缺点是需要协调管理，考虑调度优化等问题。zk为分布式管理提供服务，很多分布式产品都可以直接使用zk提供协调服务，比如solr、kafka等。</li>
</ul>
<hr>
<h2 id="Zookeeper的配置和使用"><a href="#Zookeeper的配置和使用" class="headerlink" title="Zookeeper的配置和使用"></a>Zookeeper的配置和使用</h2><p>参考文章：<a href="http://www.cnblogs.com/yuyijq/p/3438829.html" target="_blank" rel="external">Zookeeper的配置</a></p>
<h3 id="Zookeeper的安装配置"><a href="#Zookeeper的安装配置" class="headerlink" title="Zookeeper的安装配置"></a>Zookeeper的安装配置</h3><ul>
<li>linux版本下安装zk只需要官网搜索，下载，解压即可。</li>
<li>配置一个zk server主要是修改其conf文件夹中的文件。比如zoo.cfg设置为如下。</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">tickTime=2000</div><div class="line">initLimit=10</div><div class="line">syncLimit=5</div><div class="line">dataDir=/home/zju/software/zookeeper/data/2181/data</div><div class="line">dataLogDir=/home/zju/software/zookeeper/data/2181/logs</div><div class="line">clientPort=2181</div><div class="line">server.1=10.15.82.65:3888:4888</div><div class="line">server.2=10.15.82.65:3889:4889</div><div class="line">server.3=10.15.82.66:3888:4888</div></pre></td></tr></table></figure>
<ul>
<li>然后将该zk再拷贝2份，只要保证一台服务器上clientPort不冲突，server列表保持一致。</li>
<li>配置中，每个server配置中有两个TCP port，前一个是Leader和Follower或Observer交换数据使用的，后面一个是用于Zookeeper选举用的。</li>
<li>server.后面的数字，这个数字就是myid，在dataDir里会放置一个myid文件，里面就一个数字，用来唯一标识这个服务。这个id是很重要的，一定要保证整个集群中唯一。zookeeper会根据这个id来取出server.x上的配置。比如当前id为1，则对应着zoo.cfg里的server.1的配置，myid还有其他作用，比如用于leader选举等。</li>
</ul>
<h3 id="zookeeper的启动关闭脚本"><a href="#zookeeper的启动关闭脚本" class="headerlink" title="zookeeper的启动关闭脚本"></a>zookeeper的启动关闭脚本</h3><ul>
<li>启动脚本可以直接写 <code>./zookeeper-3.4.10-2181/bin/zkServer.sh start</code></li>
<li>shutdown脚本直接写 <code>./zookeeper-3.4.10-2181/bin/zkServer.sh stop</code></li>
<li>重启脚本就是先用关闭脚本，再用启动脚本。</li>
</ul>
<h2 id="Kafka的配置和使用"><a href="#Kafka的配置和使用" class="headerlink" title="Kafka的配置和使用"></a>Kafka的配置和使用</h2><h3 id="Kafka的安装配置"><a href="#Kafka的安装配置" class="headerlink" title="Kafka的安装配置"></a>Kafka的安装配置</h3><ul>
<li>linux安装kafka就是下载，解压即可。</li>
<li><p>配置kafka主要是其conf文件夹下的文件。</p>
</li>
<li><p>示例配置：使用1，2，3个broker，修改3个kafka server(称为broker)的server.properties，配置各自的id、端口号、zk的集群等。选取2个示例broker的部分配置如下。实际中，1和2在一个服务器，3在另一个服务器。</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">broker.id=1</div><div class="line">delete.topic.enable=true</div><div class="line">listeners=PLAINTEXT://10.15.82.65:9092</div><div class="line">log.dirs=/home/zju/software/kafka/data/9092/kafka-logs</div><div class="line">num.partitions=3</div><div class="line">zookeeper.connect=10.15.82.65:2181,10.15.82.65:2182,10.15.82.66:2181</div><div class="line">zookeeper.connection.timeout.ms=6000</div></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">broker.id=3</div><div class="line">delete.topic.enable=true</div><div class="line">listeners=PLAINTEXT://10.15.82.66:9092</div><div class="line">log.dirs=/home/zju/software/kafka/data/9092/kafka-logs</div><div class="line">num.partitions=3</div><div class="line">zookeeper.connect=10.15.82.65:2181,10.15.82.65:2182,10.15.82.66:2181</div><div class="line">zookeeper.connection.timeout.ms=6000</div></pre></td></tr></table></figure>
<h3 id="Kafka的使用"><a href="#Kafka的使用" class="headerlink" title="Kafka的使用"></a>Kafka的使用</h3><h4 id="使用Kafka终端进行单机连通性测试"><a href="#使用Kafka终端进行单机连通性测试" class="headerlink" title="使用Kafka终端进行单机连通性测试"></a>使用Kafka终端进行单机连通性测试</h4><ul>
<li>在Kafka的bin目录下有producer和consumer的脚本，可以直接用来进行通讯。</li>
<li>运行producer<ul>
<li><code>./bin/kafka-console-prucer.sh --broker-list 10.15.82.65:9092 --topic test</code></li>
<li>参数是指定broker列表，可以使用逗号列出多个boker列表，topic表示MQ的主题，类似于不同的信息有不同的管道。</li>
<li>输入消息，以换行作为一个结束标志。输入多行运行consumer。如果出现超时，send message出错key为null的错误，可能是Kafka集群有问题，重启集群试试。</li>
</ul>
</li>
<li>运行consumer<ul>
<li><code>./bin/kafka-console-consumer.sh --bootstrap-server 10.15.82.65:9092,10.15.82.65:9093,10.15.82.66:9092 --topic test --from-beginning</code></li>
<li>参数是bootstrap-server表示ZK集群，多个时用逗号连接，topic表示消息主题，然后从头读取所有消息。</li>
</ul>
</li>
<li>如果producer和consumer都正常，说明producer正常发送到broker集群，consumer正确取出消息，ZK集群为broker集群提供消息控制。</li>
</ul>
<h4 id="使用Java-API测试Kafka"><a href="#使用Java-API测试Kafka" class="headerlink" title="使用Java API测试Kafka"></a>使用Java API测试Kafka</h4><ul>
<li>producer测试代码</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div></pre></td><td class="code"><pre><div class="line">package com.sr.util.kafka;</div><div class="line">import org.apache.kafka.clients.producer.*;</div><div class="line">import java.util.Properties;</div><div class="line">public class TestProducer &#123;</div><div class="line">    public static final String topic = &quot;testTopic&quot;; // kafka不存在的主体会自动创建，且使用默认分区、备份等配置</div><div class="line"></div><div class="line">    public static void main(String[] args) throws Exception &#123;</div><div class="line">        Properties props = new Properties();</div><div class="line">        props.put(&quot;bootstrap.servers&quot;, &quot;10.15.82.65:9092,10.15.82.65:9093,10.15.82.66:9092&quot;);</div><div class="line"></div><div class="line">        props.put(&quot;group.id&quot;, &quot;test&quot;);</div><div class="line">        props.put(&quot;producer.type&quot;, &quot;sync&quot;); // 频繁写用异步async以进行batch发送，不频繁写可以用同步写sync</div><div class="line">        props.put(&quot;enable.auto.commit&quot;, &quot;true&quot;);</div><div class="line">        props.put(&quot;auto.commit.interval.ms&quot;, &quot;1000&quot;);</div><div class="line"></div><div class="line">        //props.put(&quot;acks&quot;, &quot;all&quot;); // 提交进行阻塞,这是最慢但最持久的设置</div><div class="line">        props.put(&quot;retries&quot;, 0);</div><div class="line">        props.put(&quot;batch.size&quot;, 16384);</div><div class="line">        props.put(&quot;linger.ms&quot;, 0); //设置为大于0的请求数可以等待以减少请求次数，但是即使为0一般也会成批发送</div><div class="line">        props.put(&quot;buffer.memory&quot;, 33554432);</div><div class="line">        props.put(&quot;key.serializer&quot;,&quot;org.apache.kafka.common.serialization.StringSerializer&quot;);</div><div class="line">        props.put(&quot;value.serializer&quot;,&quot;org.apache.kafka.common.serialization.StringSerializer&quot;);</div><div class="line"></div><div class="line"></div><div class="line">        Producer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(props);</div><div class="line">        for(int i = 0; i &lt; 1000; i++)&#123;</div><div class="line">            ProducerRecord record = new ProducerRecord&lt;&gt;(topic, Integer.toString(i), Integer.toString(i));</div><div class="line">            producer.send(record);</div><div class="line">            producer.flush(); // 强制刷新，但是上一个如果发送失败可能引起错误，但是上一个仍是异步阻塞发送啊...</div><div class="line">            System.out.println(&quot;send: &quot; + ++i);</div><div class="line">            ProducerRecord record2 = new ProducerRecord&lt;&gt;(topic, Integer.toString(i), Integer.toString(i));</div><div class="line">            producer.send(record2,</div><div class="line">                    new Callback() &#123;</div><div class="line">                        public void onCompletion(RecordMetadata metadata, Exception e) &#123;</div><div class="line">                            if(e != null)</div><div class="line">                                e.printStackTrace();</div><div class="line">                            System.out.println(&quot;The offset of the record we just sent is: &quot; + metadata.offset());</div><div class="line">                        &#125;</div><div class="line">                    &#125;);</div><div class="line">            Thread.sleep(1000);</div><div class="line">        &#125;</div><div class="line">        producer.close();</div><div class="line"></div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li>consumer测试代码</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div></pre></td><td class="code"><pre><div class="line">package com.sr.util.kafka;</div><div class="line">import org.apache.kafka.clients.consumer.ConsumerRecord;</div><div class="line">import org.apache.kafka.clients.consumer.ConsumerRecords;</div><div class="line">import org.apache.kafka.clients.consumer.KafkaConsumer;</div><div class="line"></div><div class="line">import java.util.*;</div><div class="line">public class TestConsumer &#123;</div><div class="line">	public static final String topic = &quot;testTopic&quot;;</div><div class="line"></div><div class="line">	public static void main(String[] args) throws Exception &#123;</div><div class="line">		Properties props = new Properties();</div><div class="line">		props.put(&quot;bootstrap.servers&quot;, &quot;10.15.82.65:9092,10.15.82.65:9093,10.15.82.66:9092&quot;);</div><div class="line">		props.put(&quot;group.id&quot;, &quot;test&quot;);</div><div class="line">		props.put(&quot;enable.auto.commit&quot;, &quot;true&quot;);</div><div class="line">		props.put(&quot;auto.commit.interval.ms&quot;, &quot;1000&quot;);</div><div class="line">		props.put(&quot;session.timeout.ms&quot;, &quot;30000&quot;);</div><div class="line">		props.put(&quot;key.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);</div><div class="line">		props.put(&quot;value.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);</div><div class="line">		KafkaConsumer&lt;String, String&gt; consumer = new KafkaConsumer&lt;&gt;(props);</div><div class="line">		consumer.subscribe(Arrays.asList(topic, &quot;bar&quot;));</div><div class="line">		while (true) &#123;</div><div class="line">			ConsumerRecords&lt;String, String&gt; records = consumer.poll(1);</div><div class="line">			for (ConsumerRecord&lt;String, String&gt; record : records)</div><div class="line">				System.out.printf(&quot;offset = %d, key = %s, value = %s\n&quot;, record.offset(), record.key(), record.value());</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Distributed-cluster/" rel="tag">#Distributed cluster</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/01/12/OS/MacOS/MacOS常用配置与软件/" rel="next" title="MacOS常用配置与软件">
                <i class="fa fa-chevron-left"></i> MacOS常用配置与软件
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/01/12/OS/Windows/Word/" rel="prev" title="Word">
                Word <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    


  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/statics/images/avatar.png"
               alt="gatewayzy" />
          <p class="site-author-name" itemprop="name">gatewayzy</p>
          <p class="site-description motion-element" itemprop="description">blog website with hexo and github pages</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">70</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://github.com/gatewayzy" title="Github-gatewayzy" target="_blank">Github-gatewayzy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://google.com/" title="Goolge" target="_blank">Goolge</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://wiki.jikexueyuan.com/" title="Wiki-jike" target="_blank">Wiki-jike</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Kafka-And-Zookeeper-简介"><span class="nav-number">1.</span> <span class="nav-text">Kafka And Zookeeper 简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Zookeeper的配置和使用"><span class="nav-number">2.</span> <span class="nav-text">Zookeeper的配置和使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Zookeeper的安装配置"><span class="nav-number">2.1.</span> <span class="nav-text">Zookeeper的安装配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#zookeeper的启动关闭脚本"><span class="nav-number">2.2.</span> <span class="nav-text">zookeeper的启动关闭脚本</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Kafka的配置和使用"><span class="nav-number">3.</span> <span class="nav-text">Kafka的配置和使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Kafka的安装配置"><span class="nav-number">3.1.</span> <span class="nav-text">Kafka的安装配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Kafka的使用"><span class="nav-number">3.2.</span> <span class="nav-text">Kafka的使用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#使用Kafka终端进行单机连通性测试"><span class="nav-number">3.2.1.</span> <span class="nav-text">使用Kafka终端进行单机连通性测试</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#使用Java-API测试Kafka"><span class="nav-number">3.2.2.</span> <span class="nav-text">使用Java API测试Kafka</span></a></li></ol></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">gatewayzy</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  




  
  

  
  <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
  </script>

  <script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for (i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';
      }
    });
  </script>
  <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>



  

  
<script type="text/javascript" async src="//push.zhanzhang.baidu.com/push.js">
</script>


</body>
</html>
